<template>
	<view>
		<view v-for="item in list" class="list" :data-data="item" @click="targetInformationDetails">
			<view>{{item.title}}</view>
			<view>
				<image :src="item.thumb" />
				<view>{{item.description}}</view>
			</view>
			<view>{{item.createtime}}</view>
		</view>
	</view>
</template>

<script>
	import {
		information
	} from '../../request/index.js'
	import baseUrl from '../../request/baseUrl.js'
	export default {
		data() {
			return {
				list: [],
			}
		},
		onLoad() {
			this.callback();
		},
		methods: {
			callback() {
				information().then(res => {
					this.list = res.data.list.map(item => {
						item.thumb = baseUrl + item.thumb;
						return item
					});
					console.log(this.list);
				})
			},
			targetInformationDetails(event) {
				uni.setStorageSync('informationDetails', event.currentTarget.dataset.data)
				uni.navigateTo({
					url: '/pages/informationDetails/index'
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		padding: 2vh 3.5%;
		box-sizing: border-box;
		background: #f3f3f3;
	}

	.list {
		background: white;
		padding: 1vh 2.5%;
		box-sizing: border-box;
		border-radius: 10px;
		margin-bottom: 2vh;
		box-shadow: 0 1px 5px 1px #d0d0d0;

		>view {
			&:first-child {
				font-size: 22px;
				text-align: center;
				margin-bottom: 1vh;
			}

			&:nth-child(2) {
				display: flex;
				margin-bottom: .5vh;

				>image {
					width: 22.5vw;
					height: 16.5vw;
					margin-right: 5vw;
				}

				>view {
					color: #c8c7cc;
				}
			}

			&:last-child {
				text-align: right;
				padding-right: 15%;
				color: #c8c7cc;
				box-sizing: border-box;
				font-size: 15px;
			}
		}
	}
</style>
